//
//  PhotoProgressView.m
//  Browser
//
//  Created by lizp on 2017/7/16.
//  Copyright © 2017年 ZHY. All rights reserved.
//

#import "PhotoProgressView.h"

@implementation PhotoProgressView


-(void)drawRect:(CGRect)rect {

    [super drawRect:rect];
    CGPoint center = CGPointMake(rect.size.width*0.5, rect.size.height*0.5);
    CGFloat radius = rect.size.width * 0.5 -3;
    CGFloat startAngle = -M_PI_2;
    CGFloat endAngle = M_PI*2*self.progress+startAngle;
    //创建贝塞尔曲线
    UIBezierPath *path = [[UIBezierPath alloc] init];
    [path addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES];
    //绘制一条中心的线
    [path addLineToPoint:center];
    [path closePath];
    //设置绘制颜色
    [[[UIColor alloc] initWithWhite:1.0 alpha:0.4] setFill];
    //开始绘制
    [path fill];
}

#pragma mark - set or get
-(void)setProgress:(CGFloat)progress {

    _progress = progress;
    [self setNeedsDisplay];
}

@end
